package com.jinmdz.fmis.api.api.controller;

import com.jinmdz.fmis.api.api.model.common.DictTypeData;
import com.jinmdz.fmis.api.api.model.common.TypeCodeData;
import com.jinmdz.fmis.api.api.service.ServiceItemService;
import com.jinmdz.fmis.api.base.BaseController;
import com.jinmdz.fmis.core.base.BaseResult;
import com.jinmdz.fmis.dao.model.service.ServiceItem;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.ArrayList;


/**
 * 服务项目相关接口
 *
 * @author LiCongLu
 * @date 2020-01-20 10:35
 */
@Api(description = "服务项目相关接口")
@RestController()
@RequestMapping("/api/service-item")
public class ServiceItemController extends BaseController {

    @Resource
    private ServiceItemService serviceItemService;


    /**
     * 根据业务组编码加载service_item表中服务项目信息
     *
     * @param data 请求数据
     * @return
     * @author LiCongLu
     * @date 2020-01-20 10:40
     */
    @ApiOperation(value = "根据业务组编码加载service_item表中服务项目信息", notes = "根据服务业务关联表【service_business_item】表中business_type加载服务项目表【service_item】中服务项目信息,type_code定义：接运任务用物品服务[use_in_transport_task]、冷藏业务用物品服务[use_in_cold_storage],礼厅业务用物品服务[use_in_mourn_ceremony]、整容服务[type_of_face_lift],火化用物品服务[use_in_cremation]、丧葬用品【type_of_funeral_supplies】.")
    @PostMapping("/load-service-item-with-type-code")
    public BaseResult<ArrayList<ServiceItem>> loadServiceItemWithTypeCode(@RequestBody TypeCodeData data) {
        return resultHandler(data, userItem -> serviceItemService.loadServiceItemWithTypeCode(data));
    }

    /**
     * 根据字典编码加载与字典关联的服务项目信息，一个字典编码对应一条服务项目费用记录
     *
     * @param data 请求数据
     * @return
     * @author LiCongLu
     * @date 2020-01-20 10:44
     */
    @ApiOperation(value = "根据字典编码加载与字典关联的服务项目信息，一个字典编码对应一条服务项目费用记录", notes = "根据字典data_dictionary表中data_code加载与字典关联的service_item表中服务项目信息，例如接运费用【车辆类型字典编码：transport_car_type】、冷柜费用【冷柜类型字典编码：equipment_type】、守灵厅费用【字典编码：hall_type,用途：wake_mourn_type】、告别厅费用【字典编码：hall_type,用途：farewell_mourn_type】、火化炉费用【字典编码：furnace_type】等，追加必填用途，除去礼厅之外，其他用途与字典编码相同")
    @PostMapping("/load-service-item-with-dic-type-code")
    public BaseResult<ServiceItem> loadServiceItemWithDicTypeCode(@RequestBody DictTypeData data) {
        return resultHandler(data, userItem -> serviceItemService.loadServiceItemWithDicTypeCode(data));
    }
}
